[WORDPRESS] Return highest term_taxonomy_id
Posted
by
antosha
on Stack Overflow
See other posts from Stack Overflow
or by antosha
Published on 2011-02-20T07:16:57Z
Indexed on
2011/02/20
7:24 UTC
Read the original article
Hit count: 278
Hi guys, I am trying to return the highest term taxonomy id of a post page or a taxonomy page.
I was sucessful at listing all taxonomy id's like this:
<?php
$terms = get_the_terms( $post->ID , 'mytaxonomy' );
if($terms) {
foreach( $terms as $term ) {
echo $term->term_taxonomy_id;
}
}
?>
This is what I am trying to do (return only the highest ID) (doesn't work):
<?php
$terms = get_the_terms( $post->ID , 'mytaxonomy' );
if($terms) {
foreach( $terms as $term ) {
echo max( '$term->term_taxonomy_id');
}
}
?>
Please help :)
© Stack Overflow or respective owner